package com.runmi.webchat.aftersale.web.shop.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.runmi.webchat.aftersale.common.result.Result;
import com.runmi.webchat.aftersale.dbcore.dao.ShopInfoDao;
import com.runmi.webchat.aftersale.dbcore.entity.User;
import com.runmi.webchat.aftersale.web.base.BaseController;
import com.runmi.webchat.aftersale.web.shop.service.ShopManageService;
import com.runmi.webchat.aftersale.web.shop.service.ShopUserService;
import com.runmi.webchat.aftersale.web.shop.vo.ShopManageEditReqVo;
import com.runmi.webchat.aftersale.web.shop.vo.ShopManageIndexReqVo;
import com.runmi.webchat.aftersale.web.shop.vo.ShopUserEdit;
import com.runmi.webchat.aftersale.web.shop.vo.ShopUserIndexReqVo;

@Controller
@RequestMapping(value = "/admin/shopuser")
public class ShopUserController extends BaseController{

	@Autowired
	private ShopUserService shopUserService;
	
	
	
	
	
	@RequestMapping(value = "/index")
	public ModelAndView index(HttpServletRequest request,HttpServletResponse response,ShopUserIndexReqVo model){
		ModelAndView mav = new ModelAndView("/shop/userindex");		
		shopUserService.index(model);
    	mav.addObject("model", model);
        return mav;
		//return "/customer/Customer/seach";
	}
	@PostMapping(value = "/audit")
	@ResponseBody
	public Result audit(HttpServletRequest request,HttpServletResponse response,Integer userId,Byte opType){
	
		Result result=shopUserService.audit(userId,opType);
		return result;
	}
	
	@RequestMapping(value = "/edit")
	public ModelAndView edit(HttpServletRequest request,HttpServletResponse response,ShopUserEdit model){
		//model.setUserId(this.getUserId(request, response));
		ModelAndView mav = new ModelAndView("/shop/edituser");		
		shopUserService.edit(model);
    	mav.addObject("model",model);
        return mav;
		//return "/customer/Customer/seach";
	}
	
	@PostMapping(value = "/save")
	@ResponseBody
	public Result save(
			HttpServletRequest request,HttpServletResponse response,
			Integer id,
			Integer shopId,
			String usrName,
			String realName,
			String mobile,			
			String pwd){
		return shopUserService.save(
				id,
				shopId,usrName, realName, mobile, 
				pwd,this.getUserInfo(request, response));
		
	}
}
